home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / communic / pcmail / main / rmtname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  2.7 KB  |  104 lines

  1. /*++
  2. /* NAME
  3. /*    rmtname 3
  4. /* SUMMARY
  5. /*    mapping between local and remote spool-file names
  6. /* PROJECT
  7. /*    pc-mail
  8. /* PACKAGE
  9. /*    cico
  10. /* SYNOPSIS
  11. /*    #include "params.h"
  12. /*    #include "comm.h"
  13. /*
  14. /*    char *rmtname(type,msgno)
  15. /*    int type;
  16. /*    unsigned msgno;
  17. /*
  18. /*    char *locname(rname)
  19. /*    char *rname;
  20. /* DESCRIPTION
  21. /*    locname() translates a remote spool-file name to one suitable
  22. /*    for the local file system. Remote X.* file names are converted
  23. /*    to the name of the local null device. All other remote file
  24. /*    names are mapped to names of the form n<msgno> in the local
  25. /*    spool directory.
  26. /*
  27. /*    rmtname() constructs a remote spool file name from its arguments,
  28. /*    which are a sort of broken-down local spool file name.
  29. /*    "type" specifies the type of file (Data or eXecute file).
  30. /*    "msgno" holds a sequence number.
  31. /*
  32. /*    The output for D files is: D.<rmtsys>S<xseq>
  33. /*
  34. /*    The output for X files is: X.<thissys>X<xseq>
  35. /*
  36. /*    xseq is the four-digit hexadecimal representation of
  37. /*    the sequence number in tail.
  38. /* SEE ALSO
  39. /*    getwork()
  40. /* DIAGNOSTICS
  41. /*    rmtname() returns via longjmp(systrap,E_CONFUSED) if its
  42. /*    arguments are incorrect.
  43. /* BUGS
  44. /*    locname() and rmtname() store their result in a static area which
  45. /*    is overwritten upon each call.
  46. /* AUTHOR(S)
  47. /*    W.Z. Venema
  48. /*    Eindhoven University of Technology
  49. /*    Department of Mathematics and Computer Science
  50. /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  51. /* CREATION DATE
  52. /*    Thu Mar 26 14:08:07 GMT+1:00 1987
  53. /* LAST MODIFICATION
  54. /*    90/01/22 13:02:30
  55. /* VERSION/RELEASE
  56. /*    2.1
  57. /*--*/
  58.  
  59. #include <stdio.h>
  60.  
  61. #include "defs.h"
  62. #include "params.h"
  63. #include "comm.h"
  64. #include "logs.h"
  65. #include "status.h"
  66. #include "path.h"
  67.  
  68. hidden char buf[BUFSIZ];        /* storage for the result */
  69.  
  70. /* rmtname - map local spool file name to remote spool file name */
  71.  
  72. public char *rmtname(type, msgno)
  73. int     type;
  74. unsigned msgno;
  75. {
  76.     msgno &= 0xffff;                /* truncate to four hex digs */
  77.  
  78.     switch (type) {
  79.     case 'd':                    /* data file */
  80.     case 'D':                    /* data file */
  81.     sprintf(buf, "D.%sS%04x", rmthost, msgno);
  82.     return (buf);
  83.     case 'x':                    /* execute file */
  84.     case 'X':                    /* execute file */
  85.     sprintf(buf, "X.%sX%04x", LOGIN_NAME, msgno);
  86.     return (buf);
  87.     default:                    /* oops */
  88.     trap(E_CONFUSED, "INTERNAL ERROR (unexpected file type: %c)", type);
  89.     /* NOTREACHED */
  90.     }
  91. }
  92.  
  93. /* locname - map remote spool-file name to local name */
  94.  
  95. char   *locname(rname)
  96. char   *rname;
  97. {
  98.     if (strncmp(rname, "X.", 2) == 0) {        /* X. files are ignored */
  99.     return (NULLDEV);
  100.     } else {                    /* everything else is kept */
  101.     return (new_mesg(newseqno()));
  102.     }
  103. }
  104.